home *** CD-ROM | disk | FTP | other *** search
- /*
- File: USBTabletModuleConfigParse.c
-
- Contains: xxx put contents here xxx
-
- Version: xxx put version here xxx
-
- Copyright: © 1998 by Apple Computer, Inc., all rights reserved.
-
-
- */
-
- #include <Types.h>
- #include <Devices.h>
- #include <processes.h>
- #include <DriverServices.h>
- #include <USB.h>
-
-
- #include "USBTabletModule.h"
-
- OSErr FindHIDInterfaceByNumber(LogicalAddress pConfigDesc, UInt32 ReqInterface, USBInterfaceDescriptorPtr * hInterfaceDesc)
- {
- UInt32 totalLength;
- void * pEndOfDescriptors;
- USBInterfaceDescriptorPtr pMyIntDesc;
- USBDescriptorHeaderPtr pCurrentDesc;
- unsigned long anAddress, anOffset;
-
- totalLength = USBToHostWord(((USBConfigurationDescriptorPtr)pConfigDesc)->totalLength);
- pEndOfDescriptors = (Ptr)pConfigDesc + totalLength; // get the total length and add it to the start of the config space
- pCurrentDesc = (USBDescriptorHeaderPtr)pConfigDesc; // point the currentdesc to the start of the config space
-
- while (pCurrentDesc < pEndOfDescriptors) // as long as we haven't exhausted all the descriptors
- {
- if (pCurrentDesc->descriptorType == kUSBInterfaceDesc) // look at the current descriptor
- {
- pMyIntDesc = (USBInterfaceDescriptorPtr)pCurrentDesc; // if it's an interface descriptor
- if ((pMyIntDesc->interfaceClass == kUSBHIDInterfaceClass) &&
- (pMyIntDesc->interfaceNumber == ReqInterface)) // and if it's the interface we want...
- {
- *hInterfaceDesc = pMyIntDesc; // if it is, then return with hInterfaceDesc set to the
- return noErr; // current descriptor pointer
- }
- }
- // (Ptr)pCurrentDesc += pCurrentDesc->length; // Nope, that either wasn't an interface descriptor
- anAddress = (unsigned long) pCurrentDesc; // Nope, that either wasn't an interface descriptor
- anOffset = (unsigned long) pCurrentDesc->length;
- anAddress += anOffset;
- pCurrentDesc = (USBDescriptorHeaderPtr) anAddress;
- if (pCurrentDesc->length == 0)
- break;
- } // or it was, but not the droid we're looking for.
- *hInterfaceDesc = NULL;
- return kUSBInternalErr;
- }
-
-
-
-
-